<!DOCTYPE html>
<html>
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.0.0-rc.3'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv='x-dns-prefetch-control' content='on' />

  <!-- 页面元数据 -->
  
  <title>Java 集合体系 - DataScience</title>
  
    <meta name="keywords" content="Java">
  

  
    <meta name="description" content="Java集合体系">
  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/heson525/fontawesome-pro@5.13.1/css/all.min.css">

  
  

  

  
    <link rel="shortcut icon" type='image/x-icon' href="/favicon.ico">
  

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.css">
  

  

  <!-- import link -->
  

  
    
      
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.2.0/styles/a11y-dark.css">

    
  
  
    
<link rel="stylesheet" href="/css/style.css">

  
  
  
  <!-- 脚本懒加载函数 -->
  <script>
  function loadScript(src, cb) {
    var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
    var script = document.createElement('script');
    script.setAttribute('type','text/javascript');
    if (cb) script.onload = cb;
    script.setAttribute('src', src);
    HEAD.appendChild(script);
  }
  //https://github.com/filamentgroup/loadCSS
  !function(c){"use strict";var e=function(e,t,n,r){var o,i=c.document,a=i.createElement("link");if(t)o=t;else{var d=(i.body||i.getElementsByTagName("head")[0]).childNodes;o=d[d.length-1]}var f=i.styleSheets;if(r)for(var l in r)r.hasOwnProperty(l)&&a.setAttribute(l,r[l]);a.rel="stylesheet",a.href=e,a.media="only x",function e(t){if(i.body)return t();setTimeout(function(){e(t)})}(function(){o.parentNode.insertBefore(a,t?o:o.nextSibling)});var s=function(e){for(var t=a.href,n=f.length;n--;)if(f[n].href===t)return e();setTimeout(function(){s(e)})};function u(){a.addEventListener&&a.removeEventListener("load",u),a.media=n||"all"}return a.addEventListener&&a.addEventListener("load",u),(a.onloadcssdefined=s)(u),a};"undefined"!=typeof exports?exports.loadCSS=e:c.loadCSS=e}("undefined"!=typeof global?global:this);
  </script>
  <script id="loadcss"></script>
</head>

<body>
  <header class="l_header auto shadow blur " style='opacity: 0' >
  <div class='container'>
  <div class='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a class="s-comment fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/'>
          
            <img no-lazy class='logo' src='https://7.dusays.com/2020/12/02/16aab31b3dcfe.png'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
                <li>
                  <a class="menuitem flat-box">
                    <i class='fas fa-compact-disc fa-fw music'></i>音乐
                  </a>
                  <ul class="list-v">
                    <li>
                      <div class="aplayer-container">
                        

  
    <meting-js
      theme='#1BCDFC'
      volume='0.3'
      loop='all'
      order='random'
      fixed='false'
      list-max-height='320px'
      server='netease'
      type='playlist'
      id='5229739363'
      list-folded='true'>
    </meting-js>
  


                      </div>
                    </li>
                  </ul>
                <li>
              
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fal fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="想找些什么~" />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div class="l_body">
    <div class="l_cover">
  
    
    
        <div class='cover-wrapper post featured' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://7.dusays.com/2020/09/10/bcac99047bac5.png"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">数据科学</p>
    
    
      <p class="subtitle">Welcome To A2Data</p>
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/categories/"
              
              
              id="categories">
              <i class='fal fa-folder-open fa-fw fa-fw'></i><p>内容大纲</p>
            </a>
          
            <a href="/archives/"
              
              
              id="archives">
              <i class='fal fa-archive fa-fw fa-fw'></i><p>文章归档</p>
            </a>
          
            <a href="/tags/"
              
              
              id="tags">
              <i class='fal fa-fire fa-fw fa-fw fa-fw'></i><p>热门标签</p>
            </a>
          
            <a href="/contact/"
              
              
              id="contact">
              <i class='fal fa-comments fa-fw fa-fw'></i><p>畅所欲言</p>
            </a>
          
            <a href="/Creator-said/"
              
              
              id="Creator-said">
              <i class='fal fa-microphone-alt fa-fw fa-fw'></i><p>随便说说</p>
            </a>
          
            <a href="/friends/"
              
              
              id="friends">
              <i class='fal fa-link fa-fw fa-fw'></i><p>我的朋友</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div class="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>
  
    <div class='safearea'>
      <div class='body-wrapper' id="pjax-container">
        
          <!--此文件用来存放一些不方便取值的变量--> 
<!--思路大概是将值藏到重加载的区域内--> 
 
 
 
<div id="pjax-data" style="display: none"> 
  <div id="pjax-ispage">true</div> 
  <div id="pjax-pageTitle">Java 集合体系</div> 
  <div id="pjax-enable-cover">true</div> 
  <div id="pjax-comment-path"></div> 
  <div id="pjax-comment-placeholder"></div> 
</div> 
 
 
<script> 
  // 处理封面 此时 jquery 还没加载 
  if ("none" == "none") { // 移除封面 
    document.getElementsByClassName('cover-wrapper')[0].style.display = "none"; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.add("show"); 
  } else { 
    if ("none" == "half") { // 半屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'half'); 
      document.getElementsByClassName('scroll-down')[0].style.display = "none"; 
    } else if ("none" == "full") { // 全屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'full'); 
      document.getElementsByClassName('scroll-down')[0].style.display = ""; 
    } 
    document.getElementsByClassName('cover-wrapper')[0].style.display = ""; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.remove("show"); 
  } 
</script> 
 

        
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
      <a title='Java 集合体系' href='/posts/9618.html'>
        <img class='thumbnail' src='https://gitee.com/DataITems/cdn/raw/master/20200508000334.png'>
      </a>
    
    
      <h1 class="title">
        Java 集合体系
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="https://gitee.com/DataITems/cdn/raw/master/avatar.png">
    <p>JackFeng</p>
  </a>
</div>

          
        
          
            <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：May 7, 2020</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/categories/Java/">Java</a>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>7.5k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>33 min</p>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="Java 集合体系" data-path="/posts/9618.html">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
          
            
<div class="new-meta-item comments-count">
  
  <a href="/posts/9618.html#comments">
    <i class="fas fa-comment-dots fa-fw"></i>
    <span class="valine-comment-count" data-xid="/posts/9618.html">0</span>
    <span class="leancloud-comments-count">&nbsp;</span>
  </a>
</div>


          
        
      </div>
    
  </div>


  
  
  <p>Java集合体系</p>
<a id="more"></a>


<h1 id="1、集合体系"><a href="#1、集合体系" class="headerlink" title="1、集合体系"></a>1、集合体系</h1><h2 id="0、Collection"><a href="#0、Collection" class="headerlink" title="0、Collection"></a>0、Collection</h2><blockquote>
<p>集合的体系结构：</p>
<p>​    有不同的数据结构(数据的组织，存储方式)</p>
<ul>
<li>学习方式： 最顶层</li>
<li>实现： 最底层</li>
</ul>
<p><strong>Collection—-&gt; List—&gt; ArrayList</strong></p>
<p>常用：</p>
<ul>
<li>add 添加</li>
<li>clear 清空</li>
<li>contains 是否包含指定元素</li>
<li>isEmpty 是否为空</li>
<li>remove 删除</li>
<li>size 返回集合中的元素个数</li>
<li>toArray 返回包含此集合中所有元素的数组。(遍历数组即可)</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th>Modifier and Type</th>
<th>Method and Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>boolean</code></td>
<td><code>add(E e)</code>  确保此集合包含指定的元素（可选操作）。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>addAll(Collection c)</code>  将指定集合中的所有元素添加到这个集合（可选操作）。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>clear()</code>  从这个集合中移除所有的元素（可选操作）。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>contains(Object o)</code>  返回 <code>true</code>如果集合包含指定元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>containsAll(Collection c)</code>  返回 <code>true</code>如果这个集合包含指定集合的所有元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>equals(Object o)</code>  将指定的对象与此集合进行比较，以进行相等性。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>hashCode()</code>  返回此集合的哈希代码值。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>isEmpty()</code>  返回 <code>true</code>如果集合不包含任何元素。</td>
</tr>
<tr>
<td><code>Iterator</code></td>
<td><code>iterator()</code>  返回此集合中的元素的迭代器。</td>
</tr>
<tr>
<td><code>default Stream</code></td>
<td><code>parallelStream()</code>  返回一个可能并行 <code>Stream</code>与集合的来源。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>remove(Object o)</code>  从这个集合中移除指定元素的一个实例，如果它是存在的（可选操作）。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>removeAll(Collection c)</code>  删除此集合中包含的所有元素（可选操作）的所有元素（可选操作）。</td>
</tr>
<tr>
<td><code>default boolean</code></td>
<td><code>removeIf(Predicate filter)</code>  删除满足给定谓词的这个集合的所有元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>retainAll(Collection c)</code>  仅保留包含在指定集合中的这个集合中的元素（可选操作）。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>size()</code>  返回此集合中的元素的数目。</td>
</tr>
<tr>
<td><code>default Spliterator</code></td>
<td><code>spliterator()</code>  创建此集合中的元素的 <a href="../../java/util/Spliterator.html"><code>Spliterator</code></a>。</td>
</tr>
<tr>
<td><code>default Stream</code></td>
<td><code>stream()</code>  返回一个序列 <code>Stream</code>与集合的来源。</td>
</tr>
<tr>
<td><code>Object[]</code></td>
<td><code>toArray()</code>  返回包含此集合中所有元素的数组。</td>
</tr>
<tr>
<td><code> T[]</code></td>
<td><code>toArray(T[] a)</code>  返回包含此集合中所有元素的数组；返回数组的运行时类型是指定的数组的运行时类型。</td>
</tr>
</tbody></table>
<h2 id="1、Iterator"><a href="#1、Iterator" class="headerlink" title="1、Iterator"></a>1、Iterator</h2><blockquote>
<p>集合的遍历方式：</p>
<ul>
<li>1、toArray(),可以把集合转换成数组,然后遍历数组即可 <strong>【有序】</strong></li>
<li>2、iterator(),返回迭代器对象，可以通过迭代器对象来迭代集合</li>
</ul>
<p>next() : 返回下一个元素。</p>
<p>hasNext() : 判断是否有元素可以获取</p>
<p><strong>注意：</strong></p>
<p>迭代器是依赖于集合的，相当于集合的一个副本,但迭代器在操作的时候，如果发现和集合不一样，则抛出异常。</p>
<p><em>Exception in thread “main ” java.util.ConcurrentModificationExeption</em></p>
<p><strong>解决方案：</strong></p>
<p>使用迭代器遍历时，用迭代器本身修改。</p>
<ul>
<li>List.listIterator()</li>
</ul>
</blockquote>
<pre><code class="java">package learn;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *
 * @author JackFeng
 * @date 2020/3/25
 */
public class IteratorDemo &#123;

    public static void main(String[] args) &#123;
//        method();

        // 创建集合对象
        Collection c = new ArrayList();

        //添加元素
        c.add(&quot;hello&quot;);
        c.add(&quot;2020&quot;);
        c.add(&quot;你好啊&quot;);

        //获取数组 使用迭代器
        Iterator it = c.iterator();

        while (it.hasNext())&#123;
            System.out.println(it.next());
        &#125;



    &#125;

    private static void method() &#123;
        //快捷键：CTRL + ALT + M  将代码封装成方法

        // 创建集合对象
        Collection c = new ArrayList();

        //添加元素
        c.add(&quot;hello&quot;);
        c.add(&quot;2020&quot;);
        c.add(&quot;你好啊&quot;);

        //获取数组

        Object[] objects = c.toArray();

        // 遍历数组
        for (int i = 0; i &lt;objects.length ; i++) &#123;
            System.out.println(objects[i]);
        &#125;
    &#125;

&#125;</code></pre>
<h2 id="2、迭代并发修改"><a href="#2、迭代并发修改" class="headerlink" title="2、迭代并发修改"></a>2、迭代并发修改</h2><blockquote>
<p>判断集合中是否有 “hello ” 如果有，则添加元素 “wolrd”</p>
<p><strong>异常：</strong></p>
<pre><code class="java">Exception in thread &quot;main&quot; java.util.ConcurrentModificationException</code></pre>
</blockquote>
<pre><code class="java">package learn;

import java.util.*;

/**
 *
 * @author JackFeng
 * @date 2020/3/25
 */
public class ListIteratorDemo &#123;
    public static void main(String[] args) &#123;
//        mothod();


        //创建集合对象
//        Collection c = new ArrayList();
        List c = new ArrayList();

        // 添加元素
        c.add(&quot;hello&quot;);
        c.add(&quot;2020您好&quot;);

        //迭代器遍历
/*        Iterator it = c.iterator();
        while (it.hasNext())&#123;
            String s = (String) it.next();
            if (s.equals(&quot;hello&quot;)) &#123;
                c.add(&quot;world&quot;);
            &#125;

        &#125;*/
        ListIterator lit = c.listIterator();
        while (lit.hasNext()) &#123;
            String s = (String) lit.next();
            if (s.equals(&quot;hello&quot;)) &#123;
                // 注意 使用迭代器添加，不可使用集合添加，迭代器就会同步集合
                lit.add(&quot;world&quot;);
            &#125;
        &#125;
        System.out.println(c);




    &#125;

    private static void mothod() &#123;
        //创建集合对象
        Collection c = new ArrayList();

        // 添加元素
        c.add(&quot;hello&quot;);
        c.add(&quot;2020您好&quot;);
        if (c.contains(&quot;hello&quot;))&#123;
            c.add(&quot;world&quot;);
        &#125;
        System.out.println(c);
    &#125;
&#125;</code></pre>
<h2 id="3、泛型"><a href="#3、泛型" class="headerlink" title="3、泛型"></a>3、泛型</h2><blockquote>
<p>泛型：是一种广泛的类型</p>
<p><strong>优点：</strong></p>
<ul>
<li>避免类型转换的问题</li>
<li>减少黄色警告线</li>
<li>简化代码书写</li>
</ul>
<p>什么情况使用泛型—— **<E> **</p>
</blockquote>
<pre><code class="java">package learn;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *
 * @author JackFeng
 * @date 2020/3/25
 */
public class GenericDemo &#123;

    public static void main(String[] args) &#123;

        // 创建集合对象
//        Collection c = new ArrayList();
        Collection&lt;Student&gt; c = new ArrayList&lt;Student&gt;();

        //创建元素对象
        Student s = new Student(&quot;Jack&quot;, 22);
        Student s1 = new Student(&quot;Jack1&quot;, 25);
        // 添加元素

        c.add(s);
        c.add(s1);

        //遍历集合对象
//        Iterator ir = c.iterator();
        Iterator&lt;Student&gt; ir = c.iterator();
        while (ir.hasNext()) &#123;
            // 转换出错
//            Exception in thread &quot;main&quot; java.lang.ClassCastException: learn.Student cannot be cast to java.lang.String
//            String str = (String) ir.next();
//            System.out.println(str);

            Student stu = ir.next();
            System.out.println(stu.name);

        &#125;


    &#125;

&#125;


class Student&#123;
    String name;
    int age;

    public Student(String name, int age) &#123;
        this.name = name;
        this.age = age;
    &#125;

    public String getName() &#123;
        return name;
    &#125;

    public void setName(String name) &#123;
        this.name = name;
    &#125;

    public int getAge() &#123;
        return age;
    &#125;

    public void setAge(int age) &#123;
        this.age = age;
    &#125;
&#125;</code></pre>
<h2 id="4、foreache"><a href="#4、foreache" class="headerlink" title="4、foreache"></a>4、foreache</h2><blockquote>
<p>增强for循环，一般用于遍历集合或者数组</p>
<p>格式：</p>
<ul>
<li>for（元素的类型 变量： 集合或者数组对象) {<ul>
<li>可以使用变量；</li>
</ul>
</li>
<li>}</li>
</ul>
</blockquote>
<pre><code class="java">package learn;

import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author JackFeng
 * @date 2020/3/25
 */




public class ForEachDemo &#123;
    public static void main(String[] args) &#123;


        //创建集合对象
//        Collection c = new ArrayList();
        Collection&lt;String&gt; c = new ArrayList&lt;String&gt;();

        //添加集合元素
        c.add(&quot;hello&quot;);
        c.add(&quot;20200325&quot;);

        //增强for循环
/*        for (Object obj:c
             ) &#123;
            System.out.println(obj);
        &#125;*/

        for (String string:c
             ) &#123;

            // 在增强for循环中不可修改集合 否则会出现 并发修改错误
//            c.add(&quot;123&quot;);

            System.out.println(string.toUpperCase());

        &#125;

    &#125;

&#125;</code></pre>
<h1 id="2、数据结构"><a href="#2、数据结构" class="headerlink" title="2、数据结构"></a>2、数据结构</h1><h2 id="0、数组"><a href="#0、数组" class="headerlink" title="0、数组"></a>0、数组</h2><blockquote>
<p>数组： int [] arr = { 11,12,13,14};</p>
</blockquote>
<p><strong>查找快，增删慢</strong></p>
<h2 id="1、链表"><a href="#1、链表" class="headerlink" title="1、链表"></a>1、链表</h2><blockquote>
<p>链表： 由链子连接起来的一堆结点</p>
<p><strong>结点：</strong> 地址值，值，下一个结点地址值</p>
</blockquote>
<blockquote>
<p>获取x结点 方式：</p>
<ul>
<li>遍历查找</li>
</ul>
<p>x结点的后边添加新的结点：</p>
<ul>
<li>x结点的下一个结点地址值修改为新的地址值，把新结点的下一个地址值改为 x+1</li>
</ul>
</blockquote>
<p><strong>查询慢，增删快</strong></p>
<h2 id="2、栈-amp-队列"><a href="#2、栈-amp-队列" class="headerlink" title="2、栈&amp;队列"></a>2、栈&amp;队列</h2><blockquote>
<p>栈：先进后出</p>
<p>堆：先进先出</p>
</blockquote>
<h1 id="3、集合List"><a href="#3、集合List" class="headerlink" title="3、集合List"></a>3、集合List</h1><blockquote>
<p>序列： 指哪插哪</p>
<p>特点：</p>
<ul>
<li>有序（存储和读取顺序一样）</li>
<li>整数索引</li>
<li>允许重复的</li>
</ul>
<p>功能：</p>
<ul>
<li>增   add(int index, E element)  —– 在指定索引位置添加指定元素</li>
<li>删   remove(int index)  —– 删除指定元素并返回</li>
<li>改   set(int index, E element)  —- 将指定索引位置的元素替换为指定元素，并将原来的元素返回。</li>
<li>查   get(int index) —– 根据索引返回元素(防止越界(不存在))</li>
</ul>
</blockquote>
<h2 id="常用子类"><a href="#常用子类" class="headerlink" title="常用子类"></a>常用子类</h2><blockquote>
<p>ArrayList：</p>
<ul>
<li>底层是数组结构，查询快，增删慢</li>
</ul>
<p>LinkedList:</p>
<ul>
<li>底层结构是链表，查询慢，增删快</li>
<li><strong>常用</strong><ul>
<li>void  addLast</li>
<li>getFirst</li>
<li>getLast</li>
<li>removeFirst</li>
<li>removeLast</li>
</ul>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th>Modifier and Type</th>
<th>Method and Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>boolean</code></td>
<td><code>add(E e)</code>  将指定的元素列表的结束。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>add(int index, E element)</code>  在列表中指定的位置上插入指定的元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>addAll(Collection c)</code>  追加指定集合的所有元素到这个列表的末尾，按他们的指定集合的迭代器返回。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>addAll(int index,  Collection c)</code>  将指定集合中的所有元素插入到该列表中，从指定位置开始。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>addFirst(E e)</code>  在此列表的开始处插入指定的元素。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>addLast(E e)</code>  将指定的元素列表的结束。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>clear()</code>  从这个列表中移除所有的元素。</td>
</tr>
<tr>
<td><code>Object</code></td>
<td><code>clone()</code>  返回该 <code>LinkedList</code>浅拷贝。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>contains(Object o)</code>  返回 <code>true</code>如果这个列表包含指定元素。</td>
</tr>
<tr>
<td><code>Iterator</code></td>
<td><code>descendingIterator()</code>  返回在反向顺序在deque容器元素的迭代器。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>element()</code>  检索，但不删除，此列表的头（第一个元素）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>get(int index)</code>  返回此列表中指定位置的元素。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>getFirst()</code>  返回此列表中的第一个元素。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>getLast()</code>  返回此列表中的最后一个元素。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>indexOf(Object o)</code>  返回此列表中指定元素的第一个出现的索引，或-如果此列表不包含元素，或- 1。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>lastIndexOf(Object o)</code>  返回此列表中指定元素的最后一个发生的索引，或-如果此列表不包含元素，或- 1。</td>
</tr>
<tr>
<td><code>ListIterator</code></td>
<td><code>listIterator(int index)</code>  返回此列表中元素的列表迭代器（在适当的顺序），从列表中的指定位置开始。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>offer(E e)</code>  将指定的元素添加到列表的尾部（最后一个元素）。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>offerFirst(E e)</code>  在列表的前面插入指定的元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>offerLast(E e)</code>  在列表的结尾插入指定的元素。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>peek()</code>  检索，但不删除，此列表的头（第一个元素）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>peekFirst()</code>  检索，但不删除该列表的第一个元素，或返回 <code>null</code>如果这个列表是空的。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>peekLast()</code>  检索，但不删除该列表的最后一个元素，或返回  <code>null</code>如果这个列表是空的。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>poll()</code>  检索并删除此列表的头（第一个元素）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>pollFirst()</code>  检索并移除此列表的第一个元素，或返回 <code>null</code>如果这个列表是空的。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>pollLast()</code>  检索并移除此列表的最后一个元素，或返回 <code>null</code>如果这个列表是空的。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>pop()</code>  从这个列表所表示的堆栈中弹出一个元素。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>push(E e)</code>  将一个元素推到由该列表所表示的堆栈上。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>remove()</code>  检索并删除此列表的头（第一个元素）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>remove(int index)</code>  移除此列表中指定位置的元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>remove(Object o)</code>  从该列表中移除指定元素的第一个发生，如果它是存在的。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>removeFirst()</code>  移除并返回此列表中的第一个元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>removeFirstOccurrence(Object o)</code>  删除此列表中指定元素的第一个出现（当遍历从头到尾的列表）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>removeLast()</code>  移除并返回此列表中的最后一个元素。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>removeLastOccurrence(Object o)</code>  删除此列表中指定元素的最后一次（当遍历从头到尾的列表时）。</td>
</tr>
<tr>
<td><code>E</code></td>
<td><code>set(int index, E element)</code>  用指定元素替换此列表中指定位置的元素。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>size()</code>  返回此列表中元素的数目。</td>
</tr>
<tr>
<td><code>Spliterator</code></td>
<td><code>spliterator()</code>  创建一个后期绑定和快速失败 <a href="../../java/util/Spliterator.html"><code>Spliterator</code></a>超过此列表中的元素。</td>
</tr>
<tr>
<td><code>Object[]</code></td>
<td><code>toArray()</code>  返回一个数组，包含在这个列表中的所有元素在适当的顺序（从第一个到最后一个元素）。</td>
</tr>
<tr>
<td><code> T[]</code></td>
<td><code>toArray(T[] a)</code>  返回一个数组，包含在这个列表中的所有元素在适当的顺序（从第一到最后一个元素）；返回数组的运行时类型是指定的数组的运行时类型。</td>
</tr>
</tbody></table>
<pre><code class="java">package learn;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author JackFeng
 * @date 2020/3/26
 */

/*
* 定义一个方法，返回指定列表中指定元素的索引位置
*
*
* 升级
* */


public class ListedListDemo &#123;

    public static void main(String[] args) &#123;

        List list = new ArrayList();

        list.add(&quot;hello&quot;);
        list.add(&quot;A2Data&quot;);
        list.add(&quot;scala&quot;);

        int index = index(list, &quot;python&quot;);
        System.out.println(index);


        boolean flag = contains(list, &quot;scala&quot;);
        System.out.println(flag);


        boolean flag1 = list.contains(&quot;java&quot;);
        System.out.println(flag1);


    &#125;

    public static int index(List list, Object object) &#123;

        // 索引遍历方式
        for (int i = 0; i &lt;list.size() ; i++) &#123;
            // 获取列表中的元素
            Object o = list.get(i);

            // 判断列表中的元素和指定元素是否相等
            // 如果使用 ==  是拿地址值去比较的
            if (o.equals(object))&#123;
                return i;
            &#125;

        &#125;
        // 查找不到指定元素
        return -1;

    &#125;


    public static boolean contains(List list, Object o) &#123;
        // 获取指定元素在指定列表中的索引位置
        int index = index(list, o);
        // 判断是否村子
        if (index &gt;= 0) &#123;
            return true;
        &#125; else &#123;
            return false;
        &#125;

    &#125;



&#125;</code></pre>
<h1 id="4、集合Set"><a href="#4、集合Set" class="headerlink" title="4、集合Set"></a>4、集合Set</h1><blockquote>
<p><strong>特点：</strong></p>
<ul>
<li>无序（存储和读取顺序有可能不一样）</li>
<li>不允许重复（要求元素唯一）</li>
<li>没有索引</li>
</ul>
<p>HashSet的add() 方法流程：</p>
<ul>
<li>首先会使用当前集合中的每一个元素和新添加的元素进行hash值比较</li>
<li>如果hash值不同，则直接添加新的元素</li>
<li>如果hash值相同，比较地址值，或使用 equals方法进行比较</li>
<li>比较结果一样，则认为是重复不添加</li>
<li>所有结果都不一样则添加</li>
</ul>
</blockquote>
<pre><code class="java">package learn;

import java.util.HashSet;
import java.util.Iterator;

/**
 * Created by JackFeng on 2020/3/26.
 */

/*
*使用HashSet存储字符串 并且遍历
*
* */


public class HashSetDemo &#123;
    public static void main(String[] args) &#123;
        // 创建集合对象
//        HashSet&lt;String&gt; hs = new HashSet&lt;&gt;();
        HashSet&lt;String&gt; set = new HashSet&lt;&gt;();

        //添加元素对象
        set.add(&quot;hello&quot;);
        set.add(&quot;2020&quot;);
        set.add(&quot;您好啊&quot;);

        //遍历集合
//        mothod(set);
//        method1(set);
//        method2(set);


    &#125;

    private static void method2(HashSet&lt;String&gt; set) &#123;
        //增强for
        for (String s:set
             ) &#123;
            System.out.println(s);

        &#125;
    &#125;

    private static void method1(HashSet&lt;String&gt; set) &#123;
        //迭代器
        Iterator&lt;String&gt; it = set.iterator();
        while (it.hasNext()) &#123;
            String s = it.next();
            System.out.println(s);
        &#125;
    &#125;

    private static void mothod(HashSet&lt;String&gt; set) &#123;
        //数组
        Object[] objects = set.toArray();
        for (int i = 0; i &lt;objects.length ; i++) &#123;
            System.out.println(objects[i]);
        &#125;
    &#125;
&#125;</code></pre>
<h2 id="HashSet方法优化"><a href="#HashSet方法优化" class="headerlink" title="HashSet方法优化"></a>HashSet方法优化</h2><pre><code class="java">package learn;

import java.util.HashSet;
import java.util.Objects;

/**
 *
 * @author JackFeng
 * @date 2020/3/26
 */
public class HashSetDemoTo &#123;
    public static void main(String[] args) &#123;

        //创建集合对象
        HashSet&lt;Students&gt; hs = new HashSet&lt;Students&gt;();

        //创建元素对象
        Students s = new Students(&quot;JackFeng&quot;, 22);
        Students s1 = new Students(&quot;JackFeng&quot;, 22);
        Students s2 = new Students(&quot;Jack&quot;, 25);

        //添加元素
        hs.add(s);
        hs.add(s1);
        hs.add(s2);

        //遍历集合对象
        for (Students students:hs
             ) &#123;
            System.out.println(students);

        &#125;


    &#125;
&#125;


class Students&#123;
    String name;
    int age;


    public Students(String name, int age) &#123;
        this.name = name;
        this.age = age;
    &#125;

    public String getName() &#123;
        return name;
    &#125;

    public void setName(String name) &#123;
        this.name = name;
    &#125;

    public int getAge() &#123;
        return age;
    &#125;

    public void setAge(int age) &#123;
        this.age = age;
    &#125;

    @Override
    public String toString() &#123;
        return &quot;Students&#123;&quot; +
                &quot;name=&#39;&quot; + name + &#39;\&#39;&#39; +
                &quot;, age=&quot; + age +
                &#39;&#125;&#39;;
    &#125;

    @Override
    public boolean equals(Object o) &#123;
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Students students = (Students) o;
        return age == students.age &amp;&amp;
                Objects.equals(name, students.name);
    &#125;

    @Override
    public int hashCode() &#123;
        return Objects.hash(name, age);
    &#125;
&#125;</code></pre>
<h2 id="Collections"><a href="#Collections" class="headerlink" title="Collections"></a>Collections</h2><blockquote>
<p>面试题：Collection和collections 有何区别？</p>
<ul>
<li>collection 是集合体系的最顶层，包含了集合体系的共性</li>
<li>collections 是一个工具类，方法都是用于操作collection</li>
</ul>
<p><strong>常用方法：</strong></p>
<p><code>binarySearch</code> ——- 二分查找(元素有序)</p>
<p><code>copy</code>  —— 源列表覆盖目标列表（目标》=源列表）</p>
<p><code>fill</code> —— 使用指定的对象填充指定列表的所有元素</p>
<p><code>reverse</code> —– 反转</p>
<p><code>shuffle</code> —– 随机置换</p>
<p><code>sort</code> —– 排序 （自然顺序排序）</p>
<p><code>swap</code> —- 指定列表中的两个索引位置互换</p>
</blockquote>
<table>
<thead>
<tr>
<th>Modifier and Type</th>
<th>Method and Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>static  boolean</code></td>
<td><code>addAll(Collection c,  T... elements)</code>  将所有指定的元素添加到指定的集合中。</td>
</tr>
<tr>
<td><code>static  Queue</code></td>
<td><code>asLifoQueue(Deque deque)</code>  返回一个 <a href="../../java/util/Deque.html"><code>Deque</code></a>视图为后进先出（LIFO） <a href="../../java/util/Queue.html"><code>Queue</code></a>。</td>
</tr>
<tr>
<td><code>static  int</code></td>
<td><code>binarySearch(List&gt; list,  T key)</code>  使用二进制搜索算法搜索指定对象的指定列表。</td>
</tr>
<tr>
<td><code>static  int</code></td>
<td><code>binarySearch(List list, T key, Comparator c)</code>  使用二进制搜索算法搜索指定对象的指定列表。</td>
</tr>
<tr>
<td><code>static  Collection</code></td>
<td><code>checkedCollection(Collection c, 类 type)</code>  返回一个指定集合的动态类型安全的观点。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>checkedList(List list, 类 type)</code>  返回一个动态类型安全的查看指定的列表。</td>
</tr>
<tr>
<td><code>static  Map</code></td>
<td><code>checkedMap(Map m, 类 keyType, 类 valueType)</code>  返回一个动态类型安全的查看指定的Map。</td>
</tr>
<tr>
<td><code>static  NavigableMap</code></td>
<td><code>checkedNavigableMap(NavigableMap m, 类 keyType, 类 valueType)</code>  返回一个动态类型安全的查看指定的导航电子Map。</td>
</tr>
<tr>
<td><code>static  NavigableSet</code></td>
<td><code>checkedNavigableSet(NavigableSet s, 类 type)</code>  返回一个动态类型安全的集合视图指定通航。</td>
</tr>
<tr>
<td><code>static  Queue</code></td>
<td><code>checkedQueue(Queue queue, 类 type)</code>  返回一个动态类型安全的查看指定队列。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>checkedSet(Set s, 类 type)</code>  返回一个指定的动态类型安全的观点。</td>
</tr>
<tr>
<td><code>static  SortedMap</code></td>
<td><code>checkedSortedMap(SortedMap m, 类 keyType, 类 valueType)</code>  返回一个动态类型安全的查看指定的排序图。</td>
</tr>
<tr>
<td><code>static  SortedSet</code></td>
<td><code>checkedSortedSet(SortedSet s, 类 type)</code>  返回一个动态类型安全的查看指定的排序设置。</td>
</tr>
<tr>
<td><code>static  void</code></td>
<td><code>copy(List dest, List src)</code>  将所有的元素从一个列表复制到另一个列表中。</td>
</tr>
<tr>
<td><code>static boolean</code></td>
<td><code>disjoint(Collection c1, Collection c2)</code>  返回 <code>true</code>如果两个指定集合没有共同的元素。</td>
</tr>
<tr>
<td><code>static  Enumeration</code></td>
<td><code>emptyEnumeration()</code>  返回一个没有元素的枚举。</td>
</tr>
<tr>
<td><code>static  Iterator</code></td>
<td><code>emptyIterator()</code>  返回一个没有元素的迭代器。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>emptyList()</code>  返回一个空列表（不可变）。</td>
</tr>
<tr>
<td><code>static  ListIterator</code></td>
<td><code>emptyListIterator()</code>  返回一个没有元素的列表迭代器。</td>
</tr>
<tr>
<td><code>static  Map</code></td>
<td><code>emptyMap()</code>  返回一个空Map（不可变）。</td>
</tr>
<tr>
<td><code>static  NavigableMap</code></td>
<td><code>emptyNavigableMap()</code>  返回一个空的导航Map（不可变）。</td>
</tr>
<tr>
<td><code>static  NavigableSet</code></td>
<td><code>emptyNavigableSet()</code>  返回一个空的导航集（不可变）。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>emptySet()</code>  返回一个空集（不可变）。</td>
</tr>
<tr>
<td><code>static  SortedMap</code></td>
<td><code>emptySortedMap()</code>  返回一个空的排序映射（不可变）。</td>
</tr>
<tr>
<td><code>static  SortedSet</code></td>
<td><code>emptySortedSet()</code>  返回一个空的排序集（不可变）。</td>
</tr>
<tr>
<td><code>static  Enumeration</code></td>
<td><code>enumeration(Collection c)</code>  返回指定集合的枚举数。</td>
</tr>
<tr>
<td><code>static  void</code></td>
<td><code>fill(List list, T obj)</code>  用指定元素替换指定列表的所有元素。</td>
</tr>
<tr>
<td><code>static int</code></td>
<td><code>frequency(Collection c, Object o)</code>  返回指定集合中等于指定对象的元素的数目。</td>
</tr>
<tr>
<td><code>static int</code></td>
<td><code>indexOfSubList(List source, List target)</code>  返回指定的源列表中指定的目标列表的第一个发生的起始位置，或-如果没有这样的发生，则- 1。</td>
</tr>
<tr>
<td><code>static int</code></td>
<td><code>lastIndexOfSubList(List source, List target)</code>  返回指定的源列表中指定的目标列表的最后一个发生的起始位置，或-如果没有这样的发生，则- 1。</td>
</tr>
<tr>
<td><code>static  ArrayList</code></td>
<td><code>list(Enumeration e)</code>  返回一个数组列表，该列表包含在返回的顺序中由枚举返回的元素的元素。</td>
</tr>
<tr>
<td><code>static &gt;T</code></td>
<td><code>max(Collection coll)</code>  返回最大元素的集合，根据其元素的自然排序。</td>
</tr>
<tr>
<td><code>static  T</code></td>
<td><code>max(Collection coll,  Comparator comp)</code>  返回给定集合的最大元素，根据指定的比较器诱导的顺序。</td>
</tr>
<tr>
<td><code>static &gt;T</code></td>
<td><code>min(Collection coll)</code>  返回最小的元素的集合，根据其元素的自然排序。</td>
</tr>
<tr>
<td><code>static  T</code></td>
<td><code>min(Collection coll,  Comparator comp)</code>  返回给定集合的最小元素，根据指定的比较器诱导的顺序。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>nCopies(int n,  T o)</code>  返回一个不可变列表包含指定对象的 <code>n</code>副本。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>newSetFromMap(Map map)</code>  返回一个由指定的映射支持的集合。</td>
</tr>
<tr>
<td><code>static  boolean</code></td>
<td><code>replaceAll(List list, T oldVal,  T newVal)</code>  将列表中的某一特定值的所有出现替换为另一个。</td>
</tr>
<tr>
<td><code>static void</code></td>
<td><code>reverse(List list)</code>  反转指定列表中元素的顺序。</td>
</tr>
<tr>
<td><code>static  Comparator</code></td>
<td><code>reverseOrder()</code>  返回一个比较器，对一系列的实施  <code>Comparable</code>界面对象的自然顺序相反。</td>
</tr>
<tr>
<td><code>static  Comparator</code></td>
<td><code>reverseOrder(Comparator cmp)</code>  返回一个对指定比较器的反向排序的比较器。</td>
</tr>
<tr>
<td><code>static void</code></td>
<td><code>rotate(List list, int distance)</code>  按指定的距离旋转指定列表中的元素。</td>
</tr>
<tr>
<td><code>static void</code></td>
<td><code>shuffle(List list)</code>  随机置换指定列表使用随机默认源。</td>
</tr>
<tr>
<td><code>static void</code></td>
<td><code>shuffle(List list, Random rnd)</code>  随机排列指定列表使用指定的随机源。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>singleton(T o)</code>  返回只包含指定对象的不可改变的集合。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>singletonList(T o)</code>  返回只包含指定对象的不可改变的列表。</td>
</tr>
<tr>
<td><code>static  Map</code></td>
<td><code>singletonMap(K key,  V value)</code>  返回一个不可改变的Map，只将指定的指定的键映射到指定的值。</td>
</tr>
<tr>
<td><code>static &gt;void</code></td>
<td><code>sort(List list)</code>  指定列表为升序排序，根据其元素的 <a href="../../java/lang/Comparable.html">natural  ordering</a>。</td>
</tr>
<tr>
<td><code>static  void</code></td>
<td><code>sort(List list, Comparator c)</code>  根据指定的比较器指定的顺序对指定的列表进行排序。</td>
</tr>
<tr>
<td><code>static void</code></td>
<td><code>swap(List list, int i, int j)</code>  在指定的列表中的指定位置上交换元素。</td>
</tr>
<tr>
<td><code>static  Collection</code></td>
<td><code>synchronizedCollection(Collection c)</code>  返回由指定集合支持的同步（线程安全）集合。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>synchronizedList(List list)</code>  返回由指定列表支持的同步（线程安全）列表。</td>
</tr>
<tr>
<td><code>static  Map</code></td>
<td><code>synchronizedMap(Map m)</code>  返回由指定的Map支持的同步（线程安全）Map。</td>
</tr>
<tr>
<td><code>static  NavigableMap</code></td>
<td><code>synchronizedNavigableMap(NavigableMap m)</code>  返回指定的导航Map支持的同步（线程安全）导航Map。</td>
</tr>
<tr>
<td><code>static  NavigableSet</code></td>
<td><code>synchronizedNavigableSet(NavigableSet s)</code>  返回由指定的导航集支持的同步（线程安全）导航集。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>synchronizedSet(Set s)</code>  返回一个由指定集合支持的同步（线程安全）集。</td>
</tr>
<tr>
<td><code>static  SortedMap</code></td>
<td><code>synchronizedSortedMap(SortedMap m)</code>  返回一个由指定的排序映射支持的同步（线程安全）排序的Map。</td>
</tr>
<tr>
<td><code>static  SortedSet</code></td>
<td><code>synchronizedSortedSet(SortedSet s)</code>  返回一个由指定的排序集支持的同步（线程安全）排序集。</td>
</tr>
<tr>
<td><code>static  Collection</code></td>
<td><code>unmodifiableCollection(Collection c)</code>  返回指定集合的一个不可修改的视图。</td>
</tr>
<tr>
<td><code>static  List</code></td>
<td><code>unmodifiableList(List list)</code>  返回指定列表中的一个不可修改的视图。</td>
</tr>
<tr>
<td><code>static  Map</code></td>
<td><code>unmodifiableMap(Map m)</code>  返回指定映射的一个不可修改的视图。</td>
</tr>
<tr>
<td><code>static  NavigableMap</code></td>
<td><code>unmodifiableNavigableMap(NavigableMap m)</code>  返回指定的导航电子Map的一个不可修改的视图。</td>
</tr>
<tr>
<td><code>static  NavigableSet</code></td>
<td><code>unmodifiableNavigableSet(NavigableSet s)</code>  返回指定通航设置不可修改的视图。</td>
</tr>
<tr>
<td><code>static  Set</code></td>
<td><code>unmodifiableSet(Set s)</code>  返回指定的设置不可修改的视图。</td>
</tr>
<tr>
<td><code>static  SortedMap</code></td>
<td><code>unmodifiableSortedMap(SortedMap m)</code>  返回指定的排序图上一个不可修改的视图。</td>
</tr>
<tr>
<td><code>static  SortedSet</code></td>
<td><code>unmodifiableSortedSet(SortedSet s)</code>  返回指定的排序设置不可修改的视图。</td>
</tr>
</tbody></table>
<h2 id="模拟斗地主发牌"><a href="#模拟斗地主发牌" class="headerlink" title="模拟斗地主发牌"></a>模拟斗地主发牌</h2><pre><code class="java">package learn;

import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by JackFeng on 2020/3/26.
 */

/*
*
* 模拟斗地主发牌
* */

public class CollectionsTest &#123;
    public static void main(String[] args) &#123;

        //创作扑克牌
        //花色
        String[] color = &#123;&quot;黑桃&quot;, &quot;红桃&quot;, &quot;梅花&quot;, &quot;方片&quot;&#125;;

        //数字
        String[] nums = &#123;&quot;A&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;,&quot;10&quot;,&quot;J&quot;,&quot;Q&quot;,&quot;K&quot;&#125;;

        //牌盒
        ArrayList&lt;String&gt; box = new ArrayList&lt;String&gt;();

        for (int i = 0; i &lt;color.length ; i++) &#123;
            // 得到每一个花色的牌
            for (int j = 0; j &lt;nums.length ; j++) &#123;
                // 得到每一个数字
                box.add(color[i] + nums[j]);
            &#125;
        &#125;

        box.add(&quot;大王&quot;);
        box.add(&quot;小王&quot;);

//        System.out.println(box.size());

        // 洗牌  使用置换方法
        Collections.shuffle(box);
//        System.out.println(box);

        // 牌友分牌  54-3 /3 = 17张  3张底牌
        ArrayList&lt;String&gt; A = new ArrayList&lt;String&gt;();
        ArrayList&lt;String&gt; B = new ArrayList&lt;String&gt;();
        ArrayList&lt;String&gt; C = new ArrayList&lt;String&gt;();

        for (int i = 0; i &lt;box.size() -3; i++) &#123;

            /*
            * i = 0; i % 3 = 0;
            * i = 1; i % 3 = 1;
            * i = 2; i % 3 = 2;
            * */

            if (i % 3 == 0) &#123;
                A.add(box.get(i));
            &#125; else if (i % 3 == 1) &#123;
                B.add(box.get(i));
            &#125; else if (i % 3 == 2) &#123;
                C.add(box.get(i));
            &#125;

        &#125;
        System.out.println(A);

        //底牌
        for (int i = box.size()-3; i &lt; box.size() ; i++) &#123;
            System.out.println(box.get(i));
        &#125;
        System.out.println();


    &#125;
&#125;

</code></pre>
<h1 id="5、集合Map"><a href="#5、集合Map" class="headerlink" title="5、集合Map"></a>5、集合Map</h1><h2 id="Interface-Map-lt-K-V-gt"><a href="#Interface-Map-lt-K-V-gt" class="headerlink" title="Interface Map&lt;K,V&gt;"></a>Interface Map&lt;K,V&gt;</h2><ul>
<li><p>参数类型 </p>
<p><code>K</code> -钥匙的Map保持型 </p>
<p><code>V</code> -映射的值的类型 </p>
</li>
</ul>
<blockquote>
<ul>
<li><pre><code class="java">public interface Map&lt;K,V&gt;</code></pre>
<p>映射键到值的对象。一张Map不能包含重复的键，每个键可以映射到至多一个值。 </p>
</li>
</ul>
</blockquote>
<blockquote>
<p>Map 和 Collection 的区别?</p>
<ul>
<li>Map: 双列集合,常用于处理有对应关系的数据，key是不可以重复的</li>
<li>Collection： 单列集合，collection有不同的子体系，有的允许重复有索引有序，有的不允许重复且无序。</li>
</ul>
</blockquote>
<blockquote>
<p>Map常用功能：</p>
<ul>
<li><p>映射功能</p>
<ul>
<li><code>put</code> key映射到value,若key存在，则覆盖value，并且返回原来的value；不存在则返回为null</li>
</ul>
</li>
<li><p>获取功能</p>
<ul>
<li><code>get</code> 根据指定的key 返回对应的value</li>
<li><code>Set</code>  获取所有的Key </li>
<li><code>Collection values</code>  获取所有的Value</li>
<li><code>size</code> 返回对应关系的个数</li>
</ul>
</li>
<li><p>删除功能</p>
<ul>
<li><code>clear</code> 清空所有对应关系</li>
<li><code>remove</code> 根据指定的key删除对应关系，并返回对应的value值，如果没有删除成功，返回null</li>
</ul>
</li>
<li><p>判断功能</p>
<ul>
<li><code>containsKey</code> 判断指定的key是否存在，存在返回True 否则返回False</li>
<li><code>containsValue</code> 判断指定的value是否存在</li>
<li><code>isEmpty</code>  判断是否有对应关系</li>
</ul>
</li>
<li><p>遍历功能：</p>
<ul>
<li><code>Set</code></li>
</ul>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th>Modifier and Type</th>
<th>Method and Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>void</code></td>
<td><code>clear()</code>  从这个映射中移除所有的映射（可选操作）。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>compute(K key, BiFunction remappingFunction)</code>  试图计算出指定键和当前的映射值的映射（或 <code>null</code>如果没有当前映射）。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>computeIfAbsent(K key, Function mappingFunction)</code>  如果指定的键是不是已经与价值相关的（或映射到  <code>null</code>），尝试使用给定的映射功能，进入到这个Map除非 <code>null</code>计算其价值。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>computeIfPresent(K key, BiFunction remappingFunction)</code>  如果指定键的值是存在和非空的，尝试计算一个新的映射，给出了键和它当前的映射值。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>containsKey(Object key)</code>  返回 <code>true</code>如果这Map包含一个指定的键映射。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>containsValue(Object value)</code>  返回 <code>true</code>如果映射到指定的值的一个或多个键。</td>
</tr>
<tr>
<td><code>Set&gt;</code></td>
<td><code>entrySet()</code>  返回一个 <a href="../../java/util/Set.html"><code>Set</code></a>视图的映射包含在这个Map。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>equals(Object o)</code>  将指定的对象与此映射的相等性进行比较。</td>
</tr>
<tr>
<td><code>default void</code></td>
<td><code>forEach(BiConsumer action)</code>  在该映射中的每个条目执行给定的操作，直到所有的条目被处理或操作抛出异常。</td>
</tr>
<tr>
<td><code>V</code></td>
<td><code>get(Object key)</code>  返回指定的键映射的值，或 <code>null</code>如果这个Map不包含的键映射。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>getOrDefault(Object key, V defaultValue)</code>  返回指定的键映射的值，或  <code>defaultValue</code>如果这个Map不包含的键映射。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>hashCode()</code>  返回此映射的哈希代码值。</td>
</tr>
<tr>
<td><code>boolean</code></td>
<td><code>isEmpty()</code>  返回 <code>true</code>如果这个Map不包含键值的映射。</td>
</tr>
<tr>
<td><code>Set</code></td>
<td><code>keySet()</code>  返回一个 <a href="../../java/util/Set.html"><code>Set</code></a>的关键视图包含在这个Map。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>merge(K key, V value, BiFunction remappingFunction)</code>  如果指定的键已与值相关联的值或与空值相关联的，则将其与给定的非空值关联。</td>
</tr>
<tr>
<td><code>V</code></td>
<td><code>put(K key, V value)</code>  将指定的值与此映射中的指定键关联（可选操作）。</td>
</tr>
<tr>
<td><code>void</code></td>
<td><code>putAll(Map m)</code>  从指定的映射到这个Map（可选操作）复制所有的映射。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>putIfAbsent(K key, V value)</code>  如果指定的键是不是已经与价值相关的（或映射到  <code>null</code>）将其与给定的值并返回 <code>null</code>，否则返回当前值。</td>
</tr>
<tr>
<td><code>V</code></td>
<td><code>remove(Object key)</code>  如果存在（可选操作），则从该Map中移除一个键的映射。</td>
</tr>
<tr>
<td><code>default boolean</code></td>
<td><code>remove(Object key, Object value)</code>  仅当它当前映射到指定的值时，为指定的键移除条目。</td>
</tr>
<tr>
<td><code>default V</code></td>
<td><code>replace(K key, V value)</code>  仅当它当前映射到某一值时，替换指定的键的条目。</td>
</tr>
<tr>
<td><code>default boolean</code></td>
<td><code>replace(K key, V oldValue, V newValue)</code>  仅当当前映射到指定的值时，替换指定的键的条目。</td>
</tr>
<tr>
<td><code>default void</code></td>
<td><code>replaceAll(BiFunction function)</code>  将每个条目的值替换为在该项上调用给定函数的结果，直到所有的条目都被处理或函数抛出异常。</td>
</tr>
<tr>
<td><code>int</code></td>
<td><code>size()</code>  返回这个映射中的键值映射的数目。</td>
</tr>
<tr>
<td><code>Collection</code></td>
<td><code>values()</code>  返回一个 <a href="../../java/util/Collection.html"><code>Collection</code></a>视图的值包含在这个Map。</td>
</tr>
</tbody></table>
<h2 id="Tips方法实例"><a href="#Tips方法实例" class="headerlink" title="Tips方法实例"></a>Tips方法实例</h2><pre><code class="java">package learn;

import java.util.Collection;
import java.util.HashMap;
import java.util.Set;

/**
 *
 * @author JackFeng
 * @date 2020/3/27
 */
public class MapDemo &#123;

    public static void main(String[] args) &#123;
        //创建Map对象
        HashMap&lt;String, String&gt; map = new HashMap&lt;&gt;();

        // put 映射关系
        System.out.println(map.put(&quot;001&quot;, &quot;Jack&quot;));  // 输出为null
        System.out.println(map.put(&quot;002&quot;, &quot;Jack Jie&quot;));  // 输出为null
        System.out.println(map.put(&quot;001&quot;, &quot;Jack Feng&quot;));  // 输出为Jack

        System.out.println(map); //&#123;001=Jack Feng&#125;

        //`containsKey`
        System.out.println(map.containsKey(&quot;001&quot;));

        //containsValue
        System.out.println(map.containsValue(&quot;Jack Feng&quot;));

        // clear()
//        map.clear();


        //isEmpty
//        System.out.println(map.isEmpty());
//        method(map);


        // Collection
        Collection&lt;String&gt; values = map.values();

        for (String key:values
             ) &#123;
            System.out.println(key);
        &#125;

    &#125;

    private static void method(HashMap&lt;String, String&gt; map) &#123;
        //set 不允许重复
        Set&lt;String&gt; keys= map.keySet();

        for (String key:keys
             ) &#123;
            System.out.println(key);

        &#125;
    &#125;

&#125;</code></pre>
<h2 id="Map遍历"><a href="#Map遍历" class="headerlink" title="Map遍历"></a>Map遍历</h2><blockquote>
<p>遍历方式：</p>
<ul>
<li>A(比较繁琐)：<ul>
<li>获取所有的key，遍历得到每一个key，让每个key去找对应的value</li>
</ul>
</li>
<li>B：<ul>
<li>entrySet()</li>
</ul>
</li>
</ul>
<p>使用HashMap存储数据（可以自定义对象作为Key）</p>
</blockquote>
<pre><code class="java">package learn;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author JackFeng
 * @date 2020/3/27
 */
public class MapTest &#123;
    public static void main(String[] args) &#123;
        // 创建map对象

        HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

        // 映射关系
        map.put(&quot;001&quot;, &quot;A&quot;);
        map.put(&quot;002&quot;, &quot;B&quot;);
        map.put(&quot;003&quot;, &quot;a2data.cn&quot;);


        // 第一种遍历方式
        // 方式1 获取所有的key 用过key 来获取value

        method(map);

        // 第二种遍历方式
        System.out.println(&quot;第二种遍历方式&quot;);
        Set&lt;Map.Entry&lt;String, String&gt;&gt; entries = map.entrySet();

        // 遍历集合
        // 需要用map 去修饰 Ectry ，因为是map的内部类
        // 方式2  获取entry对象 ，通过entry 对象来获取 key value

        for (Map.Entry&lt;String, String&gt; entry:entries
             ) &#123;
            // 获取 key value
            String key = entry.getKey();
            String value = entry.getValue();

            System.out.println(&quot;key:&quot;+key + &quot;-----&quot; + &quot;value:&quot;+value);

        &#125;





    &#125;

    private static void method(HashMap&lt;String, String&gt; map) &#123;
        System.out.println(&quot;第一种遍历方式&quot;);
        // 召集所有key
        Set&lt;String&gt; keys = map.keySet();

        //遍历map对象
        for (String key:keys
             ) &#123;
            // 每个key 找到value
            String value = map.get(key);
            System.out.println(&quot;key:&quot;+key + &quot;-----&quot; + &quot;value:&quot;+value);
        &#125;
    &#125;
&#125;</code></pre>
<p><strong>Key：自定义对象</strong></p>
<pre><code class="java">package learn;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 *
 * @author JackFeng
 * @date 2020/3/27
 */
public class HashMapTest &#123;
    public static void main(String[] args) &#123;

        // 创建Map对象
        HashMap&lt;Message, String&gt; hashMap = new HashMap&lt;Message,String&gt;();
        // 创建Key对象
        Message ms = new Message(&quot;未读消息&quot;,12);
        Message ms1 = new Message(&quot;已读消息&quot;,22);
        Message ms2 = new Message(&quot;已读消息&quot;,22);  // 如果想要这个不添加  重写 hashcode 和 equals

        // 添加映射关系
        hashMap.put(ms, &quot;001&quot;);
        hashMap.put(ms1, &quot;002&quot;);
        hashMap.put(ms2, &quot;002&quot;);

        // 遍历 我们使用 Entry 使用entrySet

        Set&lt;Map.Entry&lt;Message, String&gt;&gt; entrys = hashMap.entrySet();

        for (Map.Entry&lt;Message, String&gt; entry:entrys
             ) &#123;
            Message key = entry.getKey();
            String value = entry.getValue();


            System.out.println( key + value );
            // 发现输出是如下 是因为少写了 toString 方法
            //learn.Message@74a14482002
            //learn.Message@4554617c001

        &#125;


    &#125;
&#125;



class Message&#123;
    String name;
    int nums;

    public Message(String name, int nums) &#123;
        this.name = name;
        this.nums = nums;
    &#125;

    public String getName() &#123;
        return name;
    &#125;

    public void setName(String name) &#123;
        this.name = name;
    &#125;

    public int getNums() &#123;
        return nums;
    &#125;

    public void setNums(int nums) &#123;
        this.nums = nums;
    &#125;


    // 解决输出 是地址值
    @Override
    public String toString() &#123;
        return &quot;Message&#123;&quot; +
                &quot;name=&#39;&quot; + name + &#39;\&#39;&#39; +
                &quot;, nums=&quot; + nums +
                &#39;&#125;&#39;;
    &#125;


    @Override
    public boolean equals(Object o) &#123;
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Message message = (Message) o;
        return nums == message.nums &amp;&amp;
                Objects.equals(name, message.name);
    &#125;

    @Override
    public int hashCode() &#123;
        return Objects.hash(name, nums);
    &#125;
&#125;</code></pre>

  
  
    
    <div class='footer'>
      
      
        
  <div class="related_posts">
    <section class='header'>
      <i class="fas fa-bookmark fa-fw" aria-hidden="true"></i><span>相关文章</span>
    </section>
    <section class='body'>
      <div class="vlts-rps"><a class="item" href="\posts\2834.html" title="Java 常用API-II" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java 常用API-II</span><span class="excerpt">JavaAPP-II</span></a><a class="item" href="\posts\17415.html" title="Java环境" rel="bookmark "><img src="https://gitee.com/DataITems/cdn/raw/master/20200508000334.png" /><span class="title">Java环境</span><span class="excerpt">Java JDK 环境安装</span></a><a class="item" href="\posts\8589.html" title="Java面向对象(封装)" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java面向对象(封装)</span><span class="excerpt">Java面向对象 封装！</span></a><a class="item" href="\posts\32274.html" title="Java常用API" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java常用API</span><span class="excerpt">Java常用API-I</span></a><a class="item" href="\posts\43249.html" title="Java面向对象 (继承、多态)" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java面向对象 (继承、多态)</span><span class="excerpt">Java面向对象 继承 多态</span></a></div></section></div>
      
      
        <div class='copyright'>
          <blockquote>
            
              
                <p>版权声明：本网站所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="/">数据科学</a></p>

              
            
              
                <p>本文永久链接是：<a href=http://www.a2data.cn/posts/9618.html>http://www.a2data.cn/posts/9618.html</a></p>
              
            
          </blockquote>
        </div>
      
      
        <div class='donate'>
          <div class='imgs'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/alipay.jpg'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/wechat.png'>
            
          </div>
        </div>
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date" itemprop="dateUpdated" datetime="2020-09-18T10:25:49+08:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：Sep 18, 2020</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/tags/Java/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>Java</p></a></div>


        
      
        
      
        
          
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>7.5k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>33 min</p>
    </a>
  </div>


        
      
        
          
  <div class="new-meta-item share -mob-share-list">
  <div class="-mob-share-list share-body">
    
      
        <a class="-mob-share-qq" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.a2data.cn/posts/9618.html&title=Java 集合体系 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java集合体系"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png">
          
        </a>
      
    
      
        <a class="-mob-share-qzone" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=http://www.a2data.cn/posts/9618.html&title=Java 集合体系 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java集合体系"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png">
          
        </a>
      
    
      
        <a class="-mob-share-weibo" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.a2data.cn/posts/9618.html&title=Java 集合体系 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java集合体系"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png">
          
        </a>
      
    
      
        
        <div class='hoverbox'>
          <a class='share'><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/wechat.png"></a>
          <div class='target'>
            <img src="">
          </div>
        </div>
      
    
  </div>
</div>



        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/posts/4136.html'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>Anaconda闪退</p>
          <p class='content'>anaconda Windows闪退解决方案 。


anaconda 打开闪退
记录windwos 系统下 anaconda 打开闪退修复方式。

解决方式
1、 管理员模式运行
conda ...</p>
        </a>
      
      
        <a class='next' href='/posts/2834.html'>
          <p class='title'>Java 常用API-II<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>JavaAPP-II



5、API-II5.0、常用类1、Object
String toString() : 返回对象得字符串表示
​    return getClass().getNa...</p>
        </a>
      
    </div>
  
</article>


  

  <article class="post white-box reveal shadow" id="comments">
    <p ct><i class='fas fa-comments'></i> 评论</p>
    
    <div id="valine_container" class="valine_thread">
  <i class="fas fa-cog fa-spin fa-fw fa-2x"></i>
</div>

  </article>






</div>
<aside class='l_side'>
  
  
    
    

<section class="widget grid shadow desktop mobile">
  
  <header>
    
      <i class="fas fa-map-signs fa-fw" aria-hidden="true"></i><span class='name'>导航</span>
    
  </header>


  <div class='content'>
    <div class="grid navigation fixed">
      
        <a class="flat-box" title="/categories/" href="/categories/"
          
          
          id="categories">
          
            <i class="fas fa-book fa-fw fa-fw" aria-hidden="true"></i>
          
          内容大纲
        </a>
      
        <a class="flat-box" title="/archives/" href="/archives/"
          
          
          id="archives">
          
            <i class="fas fa-archive fa-fw fa-fw" aria-hidden="true"></i>
          
          文章归档
        </a>
      
        <a class="flat-box" title="/tags/" href="/tags/"
          
          
          id="tags">
          
            <i class="fas fa-fire fa-fw fa-fw" aria-hidden="true"></i>
          
          热门标签
        </a>
      
        <a class="flat-box" title="/Creator-said/" href="/Creator-said/"
          
          
          id="Creator-said">
          
            <i class="fas fa-comment-dots fa-fw fa-fw" aria-hidden="true"></i>
          
          主创说
        </a>
      
        <a class="flat-box" title="/contact/" href="/contact/"
          
          
          id="contact">
          
            <i class="fas fa-comments fa-fw fa-fw" aria-hidden="true"></i>
          
          留言板
        </a>
      
        <a class="flat-box" title="/friends/" href="/friends/"
          
          
          id="friends">
          
            <i class="fas fa-users fa-fw fa-fw" aria-hidden="true"></i>
          
          友情链接
        </a>
      
        <a class="flat-box" title="/" href="/"
          
          
            target="_blank"
          
          id="home">
          
            <i class="fas fa-clock fa-fw fa-fw" aria-hidden="true"></i>
          
          近期文章
        </a>
      
        <a class="flat-box" title="/tools/" href="/tools/"
          
          
          id="tools">
          
            <i class="fas fa-info-circle fa-fw fa-fw" aria-hidden="true"></i>
          
          软件控
        </a>
      
        <a class="flat-box" title="https://travellings.now.sh/" href="https://travellings.now.sh/"
          
            rel="noopener external nofollow noreferrer"
          
          
            target="_blank"
          
          id="https:travellingsnowsh">
          
            <i class="fa fa-binoculars fa-fw" aria-hidden="true"></i>
          
          开往
        </a>
      
    </div>
  </div>
</section>

  

  
    
    



  <section class="widget toc-wrapper shadow desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#0%E3%80%81Collection"><span class="toc-text">0、Collection</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81Iterator"><span class="toc-text">1、Iterator</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E8%BF%AD%E4%BB%A3%E5%B9%B6%E5%8F%91%E4%BF%AE%E6%94%B9"><span class="toc-text">2、迭代并发修改</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E6%B3%9B%E5%9E%8B"><span class="toc-text">3、泛型</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81foreache"><span class="toc-text">4、foreache</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0%E3%80%81%E6%95%B0%E7%BB%84"><span class="toc-text">0、数组</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E9%93%BE%E8%A1%A8"><span class="toc-text">1、链表</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E6%A0%88-amp-%E9%98%9F%E5%88%97"><span class="toc-text">2、栈&amp;队列</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E5%AD%90%E7%B1%BB"><span class="toc-text">常用子类</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HashSet%E6%96%B9%E6%B3%95%E4%BC%98%E5%8C%96"><span class="toc-text">HashSet方法优化</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Collections"><span class="toc-text">Collections</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%A8%A1%E6%8B%9F%E6%96%97%E5%9C%B0%E4%B8%BB%E5%8F%91%E7%89%8C"><span class="toc-text">模拟斗地主发牌</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Interface-Map-lt-K-V-gt"><span class="toc-text">Interface Map&lt;K,V&gt;</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Tips%E6%96%B9%E6%B3%95%E5%AE%9E%E4%BE%8B"><span class="toc-text">Tips方法实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Map%E9%81%8D%E5%8E%86"><span class="toc-text">Map遍历</span></a></li></ol>
    </div>
  </section>


  


</aside>



      </div>
      
    
    <footer class="footer clearfix">
        <br><br>
        
            
                <br>
                <div class="social-wrapper">
                    
                        
                            <a href="https://github.com/A2Data"
                               class="social fab fa-github flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=a2data@163.com"
                               class="social fas fa-envelope-open flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="tencent://AddContact/?fromId=50&amp;fromSubId=1&amp;subcmd=all&amp;uin=66860619"
                               class="social fab fa-qq flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://gitee.com/DataITems/cdn/raw/master/baeab3a662ef96c3403f558a0bb578c.jpg"
                               class="social fab fa-weixin flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://me.csdn.net/weixin_47093227"
                               class="social fab fa-cuttlefish flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                </div>
                <div>
<!--                    <span id="timeDate"></span>-->
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <span id="times"></span>
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <script>
                        var now = new Date();
                        function createtime() {
                            var grt= new Date("12/18/2018 00:00:00");  //在此处修改你的建站时间，格式：月/日/年 时:分:秒
                            now.setTime(now.getTime()+250);
                            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
                            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
                            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
                            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
                            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
                            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
                            // document.getElementById("timeDate").innerHTML = "本站已运行 "+dnum+" 天 ";
                            document.getElementById("times").innerHTML = "本站已运行 "+dnum+" 天 "+ hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
                        }
                        setInterval("createtime()",250);
                    </script>
                </div>
                <div class="pure">
                    <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
                    <script>
                        var getOSAndBrowser = function () {
                            var os = navigator.platform;
                            var userAgent = navigator.userAgent;
                            var info = "";
                            var tempArray = "";
                            if (os.indexOf("Win") > -1) {
                                if (userAgent.indexOf("Windows NT 5.0") > -1) {
                                    info += "Win2000"
                                } else if (userAgent.indexOf("Windows NT 5.1") > -1) {
                                    info += "WinXP"
                                } else if (userAgent.indexOf("Windows NT 5.2") > -1) {
                                    info += "Win2003"
                                }
                                else if (userAgent.indexOf("Windows NT 6.0") > -1) {
                                    info += "WindowsVista"
                                } else if (userAgent.indexOf("Windows NT 6.1") > -1 || userAgent.indexOf("Windows 7") > -1) {
                                    info += "Win7"
                                } else if (userAgent.indexOf("Windows NT 6.2") > -1 || userAgent.indexOf("Windows 8") > -1) {
                                    info += "Win8"
                                }
                                else if (userAgent.indexOf("Windows NT 6.3") > -1 || userAgent.indexOf("Windows 8.1") > -1) {
                                    info += "Win8.1"
                                } else if (userAgent.indexOf("Windows NT 10.0") > -1 || userAgent.indexOf("Windows 10") > -1) {
                                    info += "Win10"
                                } else {
                                    info += "Other"
                                }
                            } else if (os.indexOf("Mac") > -1) {
                                info += "Mac"
                            } else if (os.indexOf("X11") > -1) {
                                info += "Unix"
                            } else if (os.indexOf("Linux") > -1) {
                                info += "Linux"
                            } else { info += "Other" } info += "/";
                            var isOpera = userAgent.indexOf("Opera") > -1;
                            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera;
                            var isEdge = userAgent.toLowerCase().indexOf("edge") > -1 && !isIE;
                            var isIE11 = (userAgent.toLowerCase().indexOf("trident") > -1 && userAgent.indexOf("rv") > -1);
                            if (/[Ff]irefox(\/\d+\.\d+)/.test(userAgent)) {
                                tempArray = /([Ff]irefox)\/(\d+\.\d+)/.exec(userAgent);
                                info += tempArray[1] + tempArray[2]
                            } else if (isIE) {
                                var version = "";
                                var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
                                reIE.test(userAgent);
                                var fIEVersion = parseFloat(RegExp["$1"]);
                                if (fIEVersion == 7) {
                                    version = "IE7"
                                } else if (fIEVersion == 8) {
                                    version = "IE8"
                                } else if (fIEVersion == 9) { version = "IE9" } else if (fIEVersion == 10) { version = "IE10" } else { version = "0" } info += version
                            } else if (isEdge) { info += "Edge" } else if (isIE11) { info += "IE11" } else if (/[Cc]hrome\/\d+/.test(userAgent)) { tempArray = /([Cc]hrome)\/(\d+)/.exec(userAgent); info += tempArray[1] + tempArray[2] } else if (/[Vv]ersion\/\d+\.\d+\.\d+(\.\d)* *[Ss]afari/.test(userAgent)) { tempArray = /[Vv]ersion\/(\d+\.\d+\.\d+)(\.\d)* *([Ss]afari)/.exec(userAgent); info += tempArray[3] + tempArray[1] } else if (/[Oo]pera.+[Vv]ersion\/\d+\.\d+/.test(userAgent)) { tempArray = /([Oo]pera).+[Vv]ersion\/(\d+)\.\d+/.exec(userAgent); info += tempArray[1] + tempArray[2] } else { info += "unknown" } return info
                        }; document.write("欢迎来自" + returnCitySN["cname"] + "的朋友"); document.write(",您的 IP 是:" + returnCitySN["cip"]); document.write(",您使用的是:" + getOSAndBrowser());
                    </script>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://hexo.io/" target="_blank" title="由 Hexo 强力驱动">
                        <span class="badge-subject">Powered</span><span class="badge-value bg-blue">Hexo</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://beian.miit.gov.cn" target="_blank" title="[sqlsq.cn@备案]">
                        <span class="badge-subject">京ICP</span><span class="github-badge .bg-lightgrey">备20010978号</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://github.com/" target="_blank" title="静态网页托管于 GitHub Pages 和 Gitee Pages">
                        <span class="badge-subject">Hosted</span><span class="badge-value bg-brightgreen">GitHub & Gitee</span></a>
                </div>
                <br>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.foreverblog.cn/blog/1579.html" target="_blank" title="[A2Data@十年之约]">
                        <span class="badge-subject">Forever Blog</span><span class="badge-value bg-lightgrey">十年之约</span></a>
                </div>

                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.a2data.cn/" target="_blank" title="DataScience提供内容创作">
                        <span class="badge-subject">Copyright © 2018-2020</span><span class="badge-value bg-blueviolet">A2Data</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.jsdelivr.com/" target="_blank" title="jsDelivr 提供 CDN 加速服务">
                        <span class="badge-subject">CDN</span><span class="badge-value bg-orange">jsDelivr</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="本站点采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可">
                        <span class="badge-subject"><i class="fa fa-copyright"></i></span><span class="badge-value bg-lightgrey">BY-NC-SA 4.0</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://996.icu/" target="_blank" title="支持 996.ICU">
                        <span class="badge-subject">Link</span><span class="badge-value bg-red">996.ICU</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://md.openwrite.cn/" target="_blank" title="OpenWrite.cn 特约提供服务">
                        <span class="badge-subject">微信</span><span class="badge-value bg-orange">公众号编辑器</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.leileitalk.com/" target="_blank" title="类类有话说 ">
                        <span class="badge-subject">类类</span><span class="badge-value bg-red">有话说</span></a>
                </div>

            
        
    </footer>


<style>
  .github-badge {
    display:inline-block;
    border-radius:4px;
    text-shadow:none;
    font-size:13px;
    color:#fff;
    line-height:15px;
    background-color:#ABBAC3;
    margin-bottom:5px;
  }
  .github-badge .badge-subject {
    display:inline-block;
    background-color:#4D4D4D;
    padding:4px 4px 4px 6px;
    border-top-left-radius:4px;
    border-bottom-left-radius:4px;
  }
  .github-badge .badge-value {
    display:inline-block;
    padding:4px 6px 4px 4px;
    border-top-right-radius:4px;
    border-bottom-right-radius:4px;
  }
  .github-badge .bg-brightgreen {
    background-color:#4DC820 !important;
  }
  .github-badge .bg-orange {
    background-color:#FFA500 !important;
  }
  .github-badge .bg-yellow {
    background-color:#D8B024 !important;
  }
  .github-badge .bg-blueviolet {
    background-color:#8833D7 !important;
  }
  .github-badge .bg-pink {
    background-color:#F26BAE !important;
  }
  .github-badge .bg-red {
    background-color:#e05d44 !important;
  }
  .github-badge .bg-blue {
    background-color:#007EC6 !important;
  }
  .github-badge .bg-lightgrey {
    background-color:#9F9F9F !important;
  }
  .github-badge .bg-grey, .github-badge .bg-gray {
    background-color:#555 !important;
  }
  .github-badge .bg-lightgrey, .github-badge .bg-lightgray {
    background-color:#9f9f9f !important;
  }
</style>

      <a class="s-top fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md").find("img").not('.inline').not('a img').each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      // 背景层
      var bgDiv = document.createElement("div");
      $(bgDiv).addClass("bg");
      if ($(this).attr('bg')) {
        $(bgDiv).css('background', $(this).attr('bg'));
      }
      $(this).wrap(bgDiv); // 背景层
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if($(".md").find("img").not('.inline').not('a img').length+$(".article-entry").find("img").length==0)return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->



  
  
  <div id="rightmenu-wrapper">
    <ul class="list-v rightmenu" id="rightmenu-content">

      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' 
      
      
      
         onclick="menuCopy()"
              
      
         id="menu-copy-text"
      >
        <i class='fas fa-copy fa-fw'></i> 复制选中内容
      </a>
    </li>
  
        
      
        
          <li class='navigation'>
            <a class='nav icon-only fix-cursor-default' onclick='history.back()'><i class='fas fa-arrow-left fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='history.forward()'><i class='fas fa-arrow-right fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='window.location.reload()'><i class='fas fa-redo fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' href='/'><i class='fas fa-home fa-fw'></i></a>
          </li>
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://support.qq.com/products/176810/
      
      
      
      
         id="https:supportqqcomproducts176810"
              >
        <i class='fa fa-question fa-fw'></i> 吐槽墙
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/tools/
      
      
      
      
         id="tools"
              >
        <i class='fa-fw fa fa-bars fa-fw fa-fw'></i> 软件控
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://gitee.com/DataITems/cdn/raw/master/sys.png
      
      
      
      
         id="https:giteecomDataITemscdnrawmastersyspng"
              >
        <i class='fa fa-fan fa-spin fa-fw'></i> 公众号
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/about/
      
      
      
      
         id="about"
              >
        <i class='fas fa-location-arrow fa-fw'></i> 如人饮水
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/Creator-said/
      
      
      
      
         id="Creator-said"
              >
        <i class='fa fa-globe fa-fw fa-fw'></i> 冷暖自知
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          <li class='music name'>
            <p class='nav music-title fix-cursor-default'></p>
          </li>
          <li class='music ctrl'>
            <a class='nav icon-only backward' onclick='aplayerBackward()'><i class='fas fa-step-backward fa-fw'></i></a>
            <a class='nav icon-only toggle' onclick='aplayerToggle()'><i class='fas fa-play fa-fw'></i></a>
            <a class='nav icon-only forward' onclick='aplayerForward()'><i class='fas fa-step-forward fa-fw'></i></a>
          </li>
          <li class='music volume'>
            <a class='nav volume'>
              <div class="aplayer-volume-bar-wrap">
                <div class="aplayer-volume-bar fix-cursor-pointer">
                  <div class="aplayer-volume"></div>
                  <i class='left fas fa-volume-off fa-fw'></i>
                  <i class='right fas fa-volume-up fa-fw'></i>
                </div>
              </div>
            </a>
          </li>
        
      
    </ul>
  </div>
  <script>
    window.document.oncontextmenu = function (event) {
      if (event.ctrlKey || $(window).width() <= 500) {
        if (event.ctrlKey) return true;
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) return true;
      }
      setMenulocation();
      setMenuCopy();
      if (true == true) {
        try {
          checkAPlayer();
          updateTitle();
        } catch (error) {console.log(error);}
      }
      return false;
    };
    document.getElementById('rightmenu-wrapper').oncontextmenu  = function (event) {
      event.stopPropagation();  // 阻止右键上的右键
      return false;
    }
    document.querySelectorAll('img').forEach((item) => {  // IMG 放出菜单
      item.oncontextmenu  = function (event) {
        event.stopPropagation();
        return true;
      }
    })
    document.addEventListener("click", function (event) {
      hideMenu();
    });
    function hideMenu(  ) {
      document.getElementById('rightmenu-wrapper').style.display = 'none';
    }
    function setMenulocation() {
      var mymenu = document.getElementById('rightmenu-wrapper');
      var menuContent = document.getElementById('rightmenu-content');
      var mouseClientX = event.clientX;
      var mouseClientY = event.clientY;
      var menuWidth = menuContent.offsetWidth == 0 ? 160 : menuContent.offsetWidth;
      var menuHeight = menuContent.offsetHeight == 0 ? 340 : menuContent.offsetHeight;
      var screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
      var screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
      var showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
      var showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
      mymenu.style.left = showLeft + "px";
      mymenu.style.top = showTop + "px";
      mymenu.style.display = 'block';
    }
    function setMenuCopy() {
      if (window.getSelection().toString()) {
        document.getElementById('menu-copy-text').style.display = 'block';
      } else {
        document.getElementById('menu-copy-text').style.display = 'none';
      }
    }
    function menuCopy() {
      document.execCommand("Copy");
      $.message({title:'复制成功',message: window.getSelection().toString(),type:'success'});
    }
  </script>





  
<script src="/js/issues.js" aysc></script>




  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  




  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn-copy', {
        target: function (trigger) {
            return trigger.nextElementSibling
        }
    });
    function wait(callback, seconds) {
        var timelag = null;
        timelag = window.setTimeout(callback, seconds)
    }
    function pjax_initCopyCode() {
		if($(".highlight .code pre").length+$(".article pre code").length==0)return;
        var copyHtml = '';
        copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
        copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
        copyHtml += '</button>';
        $(".highlight .code pre").before(copyHtml);
        $(".article pre code").before(copyHtml);
        clipboard.off('success').on('success', function (e) {
            $.message({
            title: '复制成功',
            message: "代码已复制，请遵守相关授权协议。",
            type: 'success'
        });
            let $btn = $(e.trigger);
            $btn.addClass('copied');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-check-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPIED';
            wait(function () {
                $icon.removeClass('fa-check-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        });
        clipboard.off('error').on('error', function (e) {
            e.clearSelection();
            let $btn = $(e.trigger);
            $btn.addClass('copy-failed');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-times-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPY FAILED';
            wait(function () {
                $icon.removeClass('fa-times-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        })
    }
    $(function () {
        pjax_initCopyCode()
    });
</script>




   <script src="https://cdn.jsdelivr.net/npm/scrollreveal@4.0.6/dist/scrollreveal.min.js"></script>
<script type="text/javascript">
  function pjax_scrollrebeal() {
    ScrollReveal().reveal('.l_main .reveal', {
      distance: '32px',
      duration: '800',
      interval: '20',
      scale: '1',
      easing: 'ease-out'
    });
  }
  $(function () {
    pjax_scrollrebeal();
  });
</script>




  <script>
  let APlayerController = new Object();
  APlayerController.id = '5229739363';  // 设定全局音乐播放ID
  APlayerController.volume = '0.3';
  APlayerController.autoPlay = 'true';
</script>

  
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.js"></script>


  
<script src="https://cdn.jsdelivr.net/npm/meting@2.0/dist/Meting.min.js"></script>




  
<script src="/js/aplayer.js"></script>






  <!--https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js-->
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js"></script>

  
<script src="https://cdn.jsdelivr.net/npm/valine@1.4/dist/Valine.min.js"></script>


<script>
  var GUEST_INFO = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link'.split(',').filter(function (item) {
    return GUEST_INFO.indexOf(item) > -1
  });
  var REQUIRED_FIELDS = ['nick', 'mail', 'link'];
  var requiredFields = 'nick,mail'.split(',').filter(function (item) {
    return REQUIRED_FIELDS.indexOf(item) > -1
  });

  function emoji(path, idx, ext) {
    return path + "/" + path + "-" + idx + "." + ext;
  }

  var emojiMaps = {};
  for (var i = 1; i <= 54; i++) {
    emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
  }
  for (var i = 1; i <= 101; i++) {
    emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
  }
  for (var i = 1; i <= 116; i++) {
    emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
  }
  for (var i = 1; i <= 125; i++) {
    emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
  }
  for (var i = 1; i <= 4; i++) {
    emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
  }

  function pjax_valine() {
    if(!document.querySelectorAll("#valine_container")[0])return;

    let pagePlaceholder = $.trim($('#pjax-comment-placeholder').text()) || "嗨,请不要吝啬你的想法！小技巧：在昵称位置输入QQ号就可以自动补全邮箱哦~";

    let path = $.trim($('#pjax-comment-path').text());
    if (path.length == 0) {
      let defaultPath = '';
      path = defaultPath || decodeURI(window.location.pathname);
    }

    var valine = new Valine();
    valine.init({
      el: '#valine_container',
      meta: meta,
      placeholder: pagePlaceholder,
      path: path,
      appId: "i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz",
      appKey: "GXgwCzMM0g2CnM8x0WCM7fPQ",
      pageSize: '5',
      avatar: 'robohash',
      lang: 'zh-cn',
      visitor: 'true',
      highlight: 'true',
      mathJax: 'false',
      enableQQ: 'true',
      requiredFields: requiredFields,
      emojiCDN: 'https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/',
      emojiMaps: emojiMaps
    })
  }

  function newcomment() {

    function queryLeanCloud(k) {
      let root = this;
      let len = arguments.length;
      if (len == 1) {
        let notExist = new AV.Query("Comment");
        notExist.doesNotExist('rid');
        let isEmpty = new AV.Query("Comment");
        isEmpty.equalTo('rid', '');
        let q = AV.Query.or(notExist, isEmpty);
        if (k === '*') q.exists('url');
        else q.equalTo('url', decodeURI(k));
        q.addDescending('createdAt');
        q.addDescending('insertedAt');
        return q;
      } else {
        let ids = JSON.stringify(arguments[1]).replace(/(\[|\])/g, '');
        let cql = `select * from ${root['config']['clazzName']} where rid in (${ids}) order by -createdAt,-createdAt`;
        return AV.Query.doCloudQuery(cql)
      }
    }
    var valine = new Valine({
      el: '#valine_container_ba（因为主题已经有valine的这些参数了，这里随意填都行）',
      app_id: 'i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz',
      app_key: 'GXgwCzMM0g2CnM8x0WCM7fPQ',
      placeholder: '',
      serverURLs: 'https://i1i90mfu.lc-cn-n1-shared.com'
    });

    //判断博主，heson改为自己的昵称
    function bozhu(e){
      if (e == "Jack"){
        nick = e + '[博主]'
        return nick;
      } else {
        return e
      }
    }

    //判断网址
    function wangzhi(e){
      http = e.slice(0,4)
      https = e.slice(0,5)
      if (http == "http" || https == "https" ){
        return e
      } else if (e == "" || e == null || e == undefined){
        return e
      } else {
        e = 'http://'+ e
        return e
      }
    }

    //查询评论
    valine.Q('*').limit(7).find().then(function (comments) {
      var hotComments = $("#hot-comments");
      for (var i = 0; i < comments.length; i++) {
        if (i === 0) {
          // console.log(comments[0]);
          console.log("\n %c DataScience %c https://www.a2data.cn \n", "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;"),
          window.customElements && !window.customElements.get("meting-js") && (window.MetingJSElement = MetingJSElement,
                  window.customElements.define("meting-js", MetingJSElement));

        }
        var nick = bozhu(comments[i]._serverData.nick);
        var content = comments[i]._serverData.comment;
        // var newcontent = content.substring(0, 50).replace(/<[^>]+>/g,"");
        var newcontent = content.replace(/<[^>]+>/g,"").replace(/:.*?:/g,"[表情]").substring(0,50);
        var url = comments[i]._serverData.url;
        var link = wangzhi(comments[i]._serverData.link);
        var updatedAt = timeago(comments[i].updatedAt);
        var commentId = '#' + comments[i].id;
        hotComments.append('<div class="card-comment-item"><div class="item-header-text"><a href="'+ link +'" target="_blank" rel="nofollow noopener noreferrer" class="newcomment" >' + nick + '</a>&nbsp;发表于' + updatedAt + '</div><div class="item-text"><a href="' + url + commentId +'"  rel="nofollow" style="color:#717171" class="comments-detail" >' + newcontent + '</a></div></div>');
      }
    });
  };

  $(function () {
    pjax_valine();
    newcomment();
  });
</script>







  <script defer src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-busuanzi@2.3/js/busuanzi.pure.mini.js" data-pjax></script>


  
<script src="/js/app.js"></script>




  
    
<script src="/js/search.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/" || "/").endsWith('/') ? ("/" || "/") : ("//" || "/" );
(function ($) {
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
})(jQuery);

</script>







  
<script src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@2/js/comment_typing.js"></script>




  
    
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.1/build/highlight.min.js"></script>

    <script>hljs.initHighlightingOnLoad();</script>
  



  <script defer>

  const LCCounter = {
    app_id: 'Fsrd5NtVW8ovmaynVJ18xHO6-gzGzoHsz',
    app_key: 'QYc2X76ulK8THVLHwpJfvsrG',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'http://www.a2data.cn' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>



<!-- more -->


    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>

<!-- 样式位于：source/css/_third-party/pjaxanimate.styl -->

<div class="pjax-animate">
  
    <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>
    <div id="loading-bar-wrapper"><script>NProgress.configure({parent:"#loading-bar-wrapper",trickleSpeed: 100})</script></div>
    <script>
      window.ShowLoading = function() {
        NProgress.start();
      };
      window.HideLoading = function() {
        NProgress.done();
      }
    </script>
  
</div>

<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = ["/Creator-said/"];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      $('.l_header .switcher .s-search').removeClass('active'); // 关闭移动端激活的搜索框
      $('.l_header').removeClass('z_search-open'); // 关闭移动端激活的搜索框
      $('.wrapper').removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      $('.s-top').unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
      window.ShowLoading();
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
            newcomment();
          }
        
        
        document.querySelectorAll('pre code').forEach((block) => {
          hljs.highlightBlock(block);
        });
        
        
          pjax_scrollrebeal();
        
        
          pjax_initCopyCode();
        
        
          pjax_valine();
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
      window.HideLoading();
    });

    document.addEventListener('pjax:error', function (e) {
      window.HideLoading();
      window.location.href = e.triggerElement.href;
    });
</script>

    

      <!--聊天-->

      <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="9e16adc4-63cc-4958-bf99-26d19bf0ede8";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>

      <!--    title 变化-->
      <script type="text/javascript">
        var OriginTitile=document.title,st;
        document.addEventListener("visibilitychange",function(){
          document.hidden?(document.title="ヽ(●-`Д´-)ノ嗨说你呢，别分心",clearTimeout(st)):(document.title="(Ő∀Ő3)ノ欢迎回来！",st=setTimeout(function(){document.title=OriginTitile},3e3))
        })
      </script>

  </div>
</body>
</html>
